package com.donn.securitycontrolplatform.roletag.controller;


import com.donn.securitycontrolplatform.common.Result;
import com.donn.securitycontrolplatform.roletag.entity.TRoleTag;
import com.donn.securitycontrolplatform.roletag.service.ITRoleTagService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 标签和角色关联表 前端控制器
 * </p>
 *
 * @author zhenglixiang
 * @since 2022-06-10
 */
@RestController
@RequestMapping("/scp/api/role/tag")
@Tag(name = "role-tag-controller", description = "角色关联标签接口")
public class TRoleTagController {

    @Autowired
    ITRoleTagService service;

    @ApiOperation(value = "新增角色标签关联")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", value = "角色Id"),
            @ApiImplicitParam(name = "tagIg", value = "标签Id"),
            @ApiImplicitParam(name = "aliseName", value = "别名"),
            @ApiImplicitParam(name = "tagIdShowed", value = "是否显示标签 （ false不显示 true显示）"),
            @ApiImplicitParam(name = "aliseNameShowed", value = "是否别名 （ false不显示 true显示）")
    })
    @PostMapping("/add")
    @ResponseBody
    public Result add(@RequestBody TRoleTag roleTag) {

        return service.insertRoleTag(roleTag);
    }


    @ApiOperation(value = "修改角色标签关联")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", value = "角色Id"),
            @ApiImplicitParam(name = "tagIg", value = "标签Id"),
            @ApiImplicitParam(name = "aliseName", value = "别名"),
            @ApiImplicitParam(name = "tagIdShowed", value = "是否显示标签 （ 0不显示 1显示）"),
            @ApiImplicitParam(name = "aliseNameShowed", value = "是否别名 （ 0不显示 1显示）")
    })
    @PutMapping("/update")
    @ResponseBody
    public Result update(@RequestBody TRoleTag roleTag) {
        return service.updateRoleTag(roleTag);
    }

    @ApiOperation(value = "删除角色标签关联信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", value = "角色id")
    })
    @DeleteMapping("/delete")
    @ResponseBody
    public Result delete(@RequestParam Long roleId) {
        return service.deleteRoleTag(roleId);
    }


    @ApiOperation(value = "角色标签关联信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", value = "角色Id")
    })
    @GetMapping("/get")
    @ResponseBody
    public Result get(@RequestParam Long roleId) {
        return service.getRoleTagById(roleId);
    }

}
